package com.example.localareanetworkchat.persistence.dao

import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import com.example.localareanetworkchat.persistence.entity.ChatMessage

@Dao
interface ChatMessageDao {

    @Insert
    fun insert(chatMessage: ChatMessage)

    @Query("select * from chat_message where chat_group_id = :chatGroupId order by message_receive_timestamp desc limit 100")
    fun queryAllChatMessageByChatGroupId(chatGroupId: String): LiveData<List<ChatMessage>>

    @Query("delete from chat_message where uid = :uid and chat_group_id = :chatGroupId")
    fun deleteByUidAndChatGroupId(uid: String, chatGroupId: String)
}